package com.xmall.product.define.request.spu;

import com.xmall.validate.Money;
import com.xmall.validate.group.AddGroup;
import com.xmall.validate.group.UpdateGroup;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 返回数据格式：product - sku_info
 */
@Data
public class SkuInfoRequest implements Serializable {

    /**
     * spuID
     */
    private Long spuId;

    /**
     * 标题
     */
    @NotBlank(message = "标题不能为空", groups = { AddGroup.class, UpdateGroup.class })
    @Size(max = 200, message = "标题长度必须小于200", groups = { AddGroup.class, UpdateGroup.class })
    private String title;

    /**
     * 价格
     */
    @NotNull(message = "价格不能为空", groups = { AddGroup.class, UpdateGroup.class })
    @Money(groups = { AddGroup.class, UpdateGroup.class })
    private BigDecimal price;

    /**
     * 库存数量
     */
    @NotNull(message = "库存数量不能为空", groups = { AddGroup.class, UpdateGroup.class })
    private Integer stockNum;

    /**
     * 图片列表
     */
    @Valid
    @NotEmpty(message = "sku商品至少需要一张图片", groups = { AddGroup.class, UpdateGroup.class })
    private List<SkuImageRequest> skuImageList;

    /**
     * 销售属性列表
     */
    @Valid
    private List<SkuAttrRequest> skuAttrList;
}
